package com.qiao.train.controller;


import com.qiao.train.DAO.TrainDAO;

import com.qiao.train.po.Train;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Train")
public class TrainController {
    @Autowired
    private TrainDAO TrainDAO;

    @GetMapping("/getAllTrain")
    public List<Train> getAllTrain() {
        return TrainDAO.getAllTrain();
    }

    @GetMapping("/createTrain")
    public int createTrain(Train Train) {
        return TrainDAO.createTrain(Train);
    }

    @GetMapping("/deleteTrain")
    public int deleteTrain(int id) {
        return TrainDAO.deleteTrain(id);
    }

    @GetMapping("/updateTrain")
    public int updateTrain(Train Train) {
        return TrainDAO.updateTrain(Train);
    }
}
